package com.fndsoft.police.xuancheng.ui.base;

import android.view.View;

import com.fndsoft.police.xuancheng.R;
import com.fndsoft.police.xuancheng.view.TitleBar;
import com.fndsoft.police.xuancheng.view.TitleBar.TitleSyle;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 跟UI有关的基类
 * 
 * @author carlos carlosk@163.com
 * @version 创建时间：2014年2月19日 下午4:34:23 类说明
 */

public abstract class BaseUIFg extends BaseInterfaceFg {
	@ViewInject(R.id.titleBar)
	public TitleBar mTitleBar;

	public void showProgress() {
		if (mActivity.isLoading()) {
			return;
		}
		mActivity.hideProgress();
		mActivity.showProgress();
	}

	/**
	 * 隐藏进度条
	 * 
	 * @author carlos carlosk@163.com
	 * @version 创建时间：2013-4-1 上午6:53:35
	 */
	public void hideProgress() {
		mActivity.hideProgress();
	}

	/**
	 * 设置标题
	 * 
	 * @author carlos carlosk@163.com
	 * @version 创建时间：2013-4-1 上午6:48:41
	 * @param titleSyle
	 * @param view2
	 * @param title
	 */
	public void initTitleSyle(TitleSyle titleSyle, View view2, String title) {
		if (null == mTitleBar) {
			View view = view2.findViewById(R.id.titleBar);
			if (null != view) {
				mTitleBar = (TitleBar) view;
			} else {
				return;
			}
		}
		mTitleBar.initSyle(titleSyle, title);
		mTitleBar.leftBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				getActivity().finish();
			}
		});
	}

	public void showAlert(int resId) {
		BaseAc.currentActivity.showAlert(resId);
	}

	public void showAlert(String msg) {
		BaseAc.currentActivity.showAlert(msg);
	}
}
